package com.knoya.chejian.pda.activity

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.knoya.chejian.pda.R
import com.knoya.chejian.pda.minterface.MainButtonInterface
import com.knoya.chejian.pda.module.chuku.ChukuActivity
import com.knoya.chejian.pda.module.outsourcing.OutsourcingActivity
import com.knoya.chejian.pda.module.pandelete.PanDeleteActivity
import com.knoya.chejian.pda.module.pandian.PandianActivity
import com.knoya.chejian.pda.module.ruku.RukuActivity
import com.knoya.chejian.pda.module.shezhi.ShezhiActivity
import com.knoya.chejian.pda.module.zupan.ZupanActivity
import com.knoya.chejian.pda.module.zupanchaxun.ZupanChaxunActivity
import com.knoya.chejian.pda.myadapter.MainButtonAdapter
import com.knoya.chejian.pda.myclass.UpdataInfo
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.header_knoya.*

class MainActivity : BaseActivity(),MainButtonInterface {


    lateinit var listbutton: MutableList<String>
    lateinit var gvMainButtonAdapter : MainButtonAdapter
    override fun getLayoutId(): Int {
        when(jiemian){
            1 -> return R.layout.activity_main
            2 -> return R.layout.activity_main_2
        }
        return R.layout.activity_main
    }

    override fun initCreate() {
        tv_header_title.text = "选择操作"
        listbutton = ArrayList()
        listbutton.add("入库")
        listbutton.add("出库")
        listbutton.add("调仓")
        listbutton.add("组盘查询")
        listbutton.add("组盘")
        listbutton.add("删除组盘")
        listbutton.add("外协扫描")
        listbutton.add("包盘点")
        listbutton.add("设置")
        gvMainButtonAdapter = MainButtonAdapter(listbutton,this,this)
        GvMainButton.adapter = gvMainButtonAdapter
        UpdataInfo(this, true, sp).show()
    }

    override fun onbutton(data: String) {
        when(data){
            "入库" -> {
                val intent = Intent(this@MainActivity, RukuActivity::class.java)
                intent.putExtra("code",1)
                startActivity(intent)
            }
            "出库" -> {
                val intent = Intent(this@MainActivity, ChukuActivity::class.java)
                startActivity(intent)
            }
            "调仓" -> {
                val intent = Intent(this@MainActivity, RukuActivity::class.java)
                intent.putExtra("code",2)
                startActivity(intent)
            }
            "组盘查询" -> {
                val intent = Intent(this@MainActivity, ZupanChaxunActivity::class.java)
                startActivity(intent)
            }
            "组盘" -> {
                val intent = Intent(this@MainActivity, ZupanActivity::class.java)
                startActivity(intent)
            }
            "删除组盘" -> {
                val intent = Intent(this@MainActivity, PanDeleteActivity::class.java)
                startActivity(intent)
            }
            "外协扫描" -> {
                val intent = Intent(this@MainActivity, OutsourcingActivity::class.java)
                startActivity(intent)
            }
            "包盘点" -> {
                val intent = Intent(this@MainActivity, PandianActivity::class.java)
                startActivity(intent)
            }
            "设置" -> {
                val intent = Intent(this@MainActivity, ShezhiActivity::class.java)
                startActivity(intent)
            }
        }
    }

}
